package com.duck.user.service.impl;

import com.duck.user.dao.UserFollowDao;
import com.duck.user.service.UserFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserFollowServiceImpl implements UserFollowService {

    @Autowired
    private UserFollowDao userFollowDao;

    @Override
    public void followUser(Long followerId, Long followingId) {
        // 防止用户关注自己
        if (followerId.equals(followingId)) {
            throw new IllegalArgumentException("不能关注自己");
        }
        userFollowDao.followUser(followerId, followingId);
    }

    @Override
    public void unfollowUser(Long followerId, Long followingId) {
        userFollowDao.unfollowUser(followerId, followingId);
    }

    @Override
    public int countFollowing(Long userId) {
        return userFollowDao.countFollowing(userId);
    }

    @Override
    public int countFollowers(Long userId) {
        return userFollowDao.countFollowers(userId);
    }

    @Override
    public List<Long> getFollowingList(Long userId) {
        return userFollowDao.getFollowingList(userId);
    }

    @Override
    public List<Long> getFollowersList(Long userId) {
        return userFollowDao.getFollowersList(userId);
    }
}
